package cn.yunhe.controller;

import cn.yunhe.entity.User;
import cn.yunhe.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/UserRegNameVeryServlet")
public class UserRegNameVeryServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name=req.getParameter("name");
        UserService userService=new UserService();
        List<User> list= userService.checkRegName(name);
        PrintWriter out =resp.getWriter();
        if(list.size()>0){
            out.print("false");
        }else{
            out.print("true");
        }




    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
